package settings;



import javax.swing.JPanel;
import java.awt.Dimension;
import java.awt.Checkbox;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

import java.awt.BorderLayout;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.io.IOException;

/**
 * 
 * @author Balazs Pete
 *
 */
public class SettingsWindow extends JFrame {

	private JFrame jFrame = null;  //  @jve:decl-index=0:visual-constraint="463,84"
	private JPanel jContentPane = null;
	private JLabel jLabel = null;
	private Checkbox enableSpacesCB = null;
	private Checkbox lawToolbar = null;
	private JPanel jPanel = null;
	private Checkbox magicRob = null;
	private JButton symbolManagerButton = null;
	private JButton superAwesomeButton = null;
	private JLabel jLabel1 = null;
	private JLabel jLabel2 = null;
	private JLabel jLabel3 = null;

	public SettingsWindow(){
		setContentPane(getJContentPane());
	}
	
	/**
	 * This method initializes jFrame	
	 * 	
	 * @return javax.swing.JFrame	
	 * @author Balazs Pete
	 */
	private JFrame getJFrame() {
		if (jFrame == null) {
			jFrame = new JFrame();
			jFrame.setSize(new Dimension(346, 297));
			jFrame.setContentPane(getJContentPane());
			
		}
		return jFrame;
	}

	/**
	 * This method initializes jContentPane	
	 * 	
	 * @return javax.swing.JPanel	
	 * @author Balazs Pete
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jLabel = new JLabel();
			jLabel.setText("Settings");
			jContentPane = new JPanel();
			jContentPane.setLayout(new BorderLayout());
			jContentPane.add(jLabel, BorderLayout.NORTH);
			jContentPane.add(getJPanel(), BorderLayout.CENTER);
		}
		return jContentPane;
	}

	/**
	 * This method initializes enableSpacesCB	
	 * 	
	 * @return java.awt.Checkbox	
	 * @author Balazs Pete
	 */
	private Checkbox getEnableSpacesCB() {
		if (enableSpacesCB == null) {
			enableSpacesCB = new Checkbox("Enable Spaces",main.MainWindow.getSymbolSpacesStatus());
			enableSpacesCB.addItemListener(new ItemListener(){

				@Override
				public void itemStateChanged(ItemEvent e) {
					main.MainWindow.setEnableSymbolSpacesStatus(enableSpacesCB.getState());
				}
			});
		}
		return enableSpacesCB;
	}

	/**
	 * This method initializes lawToolbar	
	 * 	
	 * @return java.awt.Checkbox	
	 * @author Balazs Pete
	 */
	private Checkbox getLawToolbar() {
		if (lawToolbar == null) {
			lawToolbar = new Checkbox("Enable Law Toolbar",main.MainWindow.getLawToolbarStatus());
			lawToolbar.addItemListener(new ItemListener(){

				@Override
				public void itemStateChanged(ItemEvent e) {
					main.MainWindow.setEnableLawToolbarStatus(lawToolbar.getState());
				}
			});
		}
		return lawToolbar;
	}

	/**
	 * This method initializes jPanel	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJPanel() {
		if (jPanel == null) {
			GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
			gridBagConstraints3.gridx = 0;
			gridBagConstraints3.gridy = 2;
			jLabel3 = new JLabel();
			jLabel3.setText("-------");
			GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
			gridBagConstraints2.gridx = 0;
			gridBagConstraints2.gridy = 1;
			jLabel2 = new JLabel();
			jLabel2.setText("~Italic~");
			GridBagConstraints gridBagConstraints12 = new GridBagConstraints();
			gridBagConstraints12.gridx = 0;
			gridBagConstraints12.gridy = 0;
			jLabel1 = new JLabel();
			jLabel1.setText("#Bold#");
			GridBagConstraints gridBagConstraints1111 = new GridBagConstraints();
			gridBagConstraints1111.gridx = 0;
			gridBagConstraints1111.gridy = 7;
			GridBagConstraints gridBagConstraints111 = new GridBagConstraints();
			gridBagConstraints111.gridx = 0;
			gridBagConstraints111.gridy = 6;
			GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
			gridBagConstraints11.gridx = 0;
			gridBagConstraints11.gridy = 5;
			GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
			gridBagConstraints1.gridx = 0;
			gridBagConstraints1.gridy = 4;
			GridBagConstraints gridBagConstraints = new GridBagConstraints();
			gridBagConstraints.gridx = 0;
			gridBagConstraints.gridy = 3;
			jPanel = new JPanel();
			jPanel.setLayout(new GridBagLayout());
			jPanel.add(getEnableSpacesCB(), gridBagConstraints);
			jPanel.add(getLawToolbar(), gridBagConstraints1);
			jPanel.add(getMagicRob(), gridBagConstraints11);
			jPanel.add(getSymbolManagerButton(), gridBagConstraints111);
			jPanel.add(getSuperAwesomeButton(), gridBagConstraints1111);
			jPanel.add(jLabel1, gridBagConstraints12);
			jPanel.add(jLabel2, gridBagConstraints2);
			jPanel.add(jLabel3, gridBagConstraints3);
		}
		return jPanel;
	}

	/**
	 * This method initializes magicRob	
	 * 	
	 * @return java.awt.Checkbox	
	 */
	private Checkbox getMagicRob() {
		if (magicRob == null) {
			magicRob = new Checkbox("Magic Rob");
			magicRob.setState(main.MainWindow.getMagicRob());
			magicRob.addItemListener(new ItemListener(){

				@Override
				public void itemStateChanged(ItemEvent e) {
					main.MainWindow.setEnableLawToolbarStatus(lawToolbar.getState());
					if(magicRob.getState()){
						superAwesomeButton.setVisible(true);
					} else {
						superAwesomeButton.setVisible(false);
					}
				}
			});
		}
		return magicRob;
	}


	/**
	 * This method initializes magicRob	
	 * 	
	 * @return java.awt.Checkbox	
	 */
	private JButton getSymbolManagerButton() {
		if (symbolManagerButton == null) {
			symbolManagerButton = new JButton("Symbol Manager");
			symbolManagerButton.addMouseListener(new MouseListener(){

				@Override
				public void mouseClicked(MouseEvent e) {
					main.MainWindow.showShortcutManager(true);
					main.MainWindow.settingsVisible(false);
				}

				@Override
				public void mousePressed(MouseEvent e) {
				}
				
				@Override
				public void mouseReleased(MouseEvent e) {
				}

				@Override
				public void mouseEntered(MouseEvent e) {
				}

				@Override
				public void mouseExited(MouseEvent e) {
				}
				
			});
		}
		return symbolManagerButton;
	}
	
	/**
	 *  @Gary Doyle
	 */
	
	
	private JButton getSuperAwesomeButton() {
		if (superAwesomeButton == null) {
			superAwesomeButton = new JButton("Super Awesome");
			superAwesomeButton.addMouseListener(new MouseListener(){
				
				
				public void mouseClicked(MouseEvent e) {
				new errors.RandomError(13);
				main.MainWindow.settingsVisible(false);
			}

			@Override
			public void mousePressed(MouseEvent e) {
			}

			@Override
			public void mouseReleased(MouseEvent e) {
			}

			@Override
			public void mouseEntered(MouseEvent e) {
			}

			@Override
			public void mouseExited(MouseEvent e) {
			}
			
		});
			if(magicRob.getState()==false){
				superAwesomeButton.setVisible(false);
			}
	}
	return superAwesomeButton;
}	
}
